#!/bin/bash
 
#> File Name:        test.sh
#> Author:           MagicYang
#> Version:          1.0.1
#> Mail:             476080754@qq.com
#> Created Time:     2022-10-08 11:22:06
 
TARGET_DIR=/home/yhb/source_code/github/libtools/libtools
COUNT_NUM=0
echo target_dir:$TARGET_DIR

func_1()
{
    for i in $TARGET_FILES
    do
        #echo target_file:$i
        file=${i#*/}
        #echo file:$file
        src_file=$(find $TARGET_DIR -name "$file")
        COUNT_NUM=0
        for r in $src_file
        do
            #echo src_file:$r
            let COUNT_NUM=COUNT_NUM+1
        done

        if [ $COUNT_NUM -gt 1 ]; then
            echo $src_file
        else
            cp $src_file $file
        fi
    done
}

if [ x$TARGET_DIR != x ]; then
    TARGET_FILES=`ls ./*.h`
    func_1

    TARGET_FILES=`ls ./*.c`
    func_1
fi
